<?php
use yii\helpers\Url;
use yii\web\View;
use app\assets\NewVideoCreativeAsset;
NewVideoCreativeAsset::register($this);
$this->title = '新增视频创意';
$jsMsgs = $this->context->loadJsMsgs([
  'creativeForm'
]);
$this->registerJs("VAM.setVar('LANGUAGE_JS', '".$jsMsgs."');", View::POS_HEAD);
?>
<style>
  html,body{background-color: #fff;} 
</style>
<div class="panel mb0">
  <div class="panel-heading">
  </div>
  <div class="panel-body">
    <div class="row">
      <div class="col-sm-6 col-sm-offset-3">
        <form class="form-horizontal" id="data-frm" method="POST" action="<?php echo Url::to(['creative/new-app-creative-handle']);?>">
      <input class="hidden" type="text" name="solution_id" value="<?=$solutionId?>">
          <input class="hidden" type="text" name="id" value="">
          <fieldset>
            <legend>创意信息</legend>
            <div class="form-group">
              <label class="col-sm-2 control-label" for="creative_name" >
                <em>*</em>
                创意名称：
              </label>
              <div class="col-sm-10">
                <input class="form-control" id="creative_name" type="text" name="name" value="" placeholder="创意名称">
                <div class="help-block text-error" id="creative_name_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label" for="creative_vocation_large" >
                <em>*</em>
                创意行业：
              </label>
              <div class="col-sm-5">
                <select class="form-control" id="creative_vocation_large" name="parent_category">
                </select>
              </div>
              <div class="col-md-5">
                <select class="form-control" id="creative_vocation_small" name="category">
                </select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label" for="advertiser_name" >
                广告主名称：
              </label>
              <div class="col-sm-10">
                <input class="form-control" id="advertiser_name" type="text" name="advertiser_name" value="" placeholder="广告主名称">
                <div class="help-block text-error" id="advertiser_name_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label" for="landing_page_url">
                <em>*</em>
                目标地址：
              </label>
              <div class="col-sm-10">
                <input class="form-control" id="landing_page_url" type="text" name="landing_page" value="" placeholder="http(s)://">
                <div class="help-block text-error" id="landing_page_url_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label" for="landing_page_main_url">
                落地页主域名：
              </label>
              <div class="col-sm-10">
                <input class="form-control" id="landing_page_main_url" type="text" name="adomain" value="" placeholder="请填写一级域名或者二级域名。">
                <div class="help-block text-error" id="landing_page_main_url_err"></div>
                <p class="help-block">提示：如果网站URL是http://www.baidu.com，只需填写baidu.com；如果网站URL是http://www.sina.com.cn，只需填写sina.com.cn。</p>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label" for="impr_monitor_url">
                第三方曝光监测：
              </label>
              <div class="col-sm-10">
                <input class="form-control" id="impr_monitor_url" type="text" name="show_monitor_url" value="" placeholder="http(s)://">
                <div class="help-block text-error" id="impr_monitor_url_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label" for="click_monitor_url" >
                第三方点击监测：
              </label>
              <div class="col-sm-10">
                <input class="form-control" id="click_monitor_url" type="text" name="click_monitor_url" value="" placeholder="http(s)://">
                <div class="help-block text-error" id="click_monitor_url_err"></div>
              </div>
            </div>      
            <div class="form-group vm-hidden">
        <label for="belong_creative" class="col-sm-2 control-label">
                创意模板：
        </label>
              <div class="col-sm-10">
                <select class="form-control" id="belong_creative" name="template_id" placeholder="创意模板">
          <?php 
            foreach($templates as $template) {
              $id = $template['id'];
              $name = $template['name'];
              echo "<option value='$id'>$name</option>";
            }
          ?>
                </select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label" for="alternative_creative_size">
                有效素材尺寸：
              </label>
              <div class="col-sm-10">
                <p class="form-control-static" id="alternative_creative_size" name="alternative_creative_size"><?php 
        $sizeList = [];
        foreach ($vsizes as $k => $size) {
          $sizeList[] = $size['width'].'*'.$size['height'];
        }
        $sizeList = array_unique($sizeList);
        sort($sizeList);
        foreach ($sizeList as $k => $size) {
          echo $size.',  ';
          if(($k+1)%9 == 0) echo '</br>';
        }
        ?></p>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label" for="alternative_creative_size">
                有效素材格式：
              </label>
              <div class="col-sm-10">
                <p class="form-control-static" id="alternative_creative_size" name="alternative_creative_size">JPG,PNG,SWF,FLV,MP4</p>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label" for="upload_material">
                <em>*</em>
                上传素材：
              </label>
              <div class="col-sm-2 col-sm-offset-8">
                <button class="btn btn-info" id="upload-material" type="button">
                  <i class="fa fa-upload"></i>
                  上传
                </button>
              </div>
              <div class="col-sm-12 mt10 text-center">
                <div class="creative-preview-wrap">
                </div>
                <img class="img-thumbnail creative_material_default" id="creative_material_default" src="holder.js/310x260/text:未上传" alt="未上传">
                <input id="upload_material" name="upload_material" type="hidden" value="">
                <div class="help-block text-error" id="upload_material_err"></div>
              </div>
            </div>
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
                <div class="btn-form-group pull-right">
                  <input class="operate-type" type="hidden" name="operate_type" value="save">
                  <button type="submit" class="btn btn-primary" data-loading-text="<i class='fa fa-spinner fa-spin'></i> 数据提交中...">保存</button>
                  <a href="<?php echo Url::to(['creative/index']);?>" class="btn btn-default">返回列表</a>
                </div>
              </div>
            </div>
          </fieldset>
        </form>
      </div>
    </div>
  </div>
</div>
<div class="modal fade" id="upload-material-modal">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title">上传素材</h4>
      </div>
      <div class="modal-body">
        <div class="portlet-content">
          <span class="btn btn-success btn-sm fileinput-button">
            <i class="fa fa-plus"></i>
            <span>选择文件</span>
            <input id="creative-id" type="hidden" name="creative_id" value="${id}" >
            <!-- The file input field used as target for the file upload widget -->
            <input type="file" multiple="" name="files[]" id="fileupload">
          </span>
          <br>
          <br>
          <!-- The global progress bar -->
          <div class="progress" id="progress">
              <div aria-valuemax="100" aria-valuemin="0" class="progress-bar progress-bar-success progress-bar-striped">0%</div>
          </div>
          <!-- The container for the uploaded files -->
          <div class="files" id="files">
            <table class="table table-striped table-bordered">
              <thead>
                <tr>
                  <th>ID</th>
                  <th>文件名称</th>
                  <th>文件大小(KB)</th>
                  <th>上传时间</th>
                  <th>判断信息</th>
                  <th>上传者</th>
                </tr>
              </thead>
              <tbody></tbody>
              </table>
            </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" id="upload-confirm-operate" data-material-id="">确定</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<?php
  $uploadMaterialUrl = Url::to(['creative/upload-video']);
  $videoPluginUrl = Yii::getAlias('@web/').Yii::$app->params['envDir'].'/js/vendor/flowplayer/flowplayer.swf';
  $creativeVocation = $categories;
  //$creativeVocation = '{"汽车":["车讯行情","车辆养护","配件改装","其它"],"新闻":["军事","时政要闻","产经","科技","其它"],"财经":["股票","基金","理财","房产","保险","收藏","其它"],"数码":["电脑","手机","数码设备","软件","APP","其它"],"医疗":["健康养生","疾病治疗","整形美容","两性","其它"],"娱乐影音":["影视","音乐","图书","图片","星座","明星","游戏","宠物","休闲活动","其它"],"社交与网络服务":["婚恋交友","SNS","论坛","网络服务"],"教育":["幼教","应试","考研","培训","MBA","出国","自考","其它"],"家居家电":["家电","家具","装修","装饰","日常用品"],"体育":["足球","篮球","网球","户外","健身","器材","其它"],"旅行":["酒店和住宿","旅行社和服务","票务服务"],"女性":["时尚","美容","母婴"],"职业":["简历","招聘信息","其它"],"食品饮料":["美食","零食","饮料","烟酒","保健食品","其它"],"服饰鞋包":["服装","鞋靴","配饰","珠宝首饰","箱包","钟表","奢侈品","眼镜"],"工农业":["电子电工","机械设备","农林牧渔","化工及材料"],"生活和商务服务":["生活服务","商务服务"]}';
  $this->registerJs("VAM.setVar('UPLOAD_MATERIAL_URL','$uploadMaterialUrl');", View::POS_HEAD);
  $this->registerJs("VAM.setVar('VIDEO_PLUGIN_URL','$videoPluginUrl');", View::POS_HEAD);
  $this->registerJs("VAM.setVar('CREATIVE_VOCATION','$creativeVocation')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('CLOSE_DIALOG_FLAG',true)", View::POS_HEAD);
?>
<script type="text/javascript" >
  requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/site.js"], function(common) {
    requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/creative/newVideoCreative.js"]);
  });
</script>